package org.pqsoft.fdemo.service;

import java.util.List;
import java.util.Map;

import com.mframework.system.BaseDao;
import com.mframework.system.PageTemplate;

public class FDemoService 
{

	private BaseDao<?> dao = BaseDao.newInstance();

	//查询方法
	public PageTemplate selectbp(Map<String, Object> param)   //PARAM=MAPS
	{
		int pageCurr = 1;
		int pageCount =7;
		
		if (!(param.get("PAGE_CURR") == null || "".equals(param.get("PAGE_CURR").toString().trim())))
		{
			pageCurr = Integer.parseInt(param.get("PAGE_CURR").toString());
		}
		if (!(param.get("PAGE_COUNT") == null || "".equals(param.get("PAGE_COUNT").toString().trim())))
		{
			pageCount = Integer.parseInt(param.get("PAGE_COUNT").toString());
		}
		
		param.put("PAGE_BEGIN", pageCount * (pageCurr - 1) + 1);
		param.put("PAGE_END", pageCount * pageCurr);
		
		List<?> list = dao.selectForList("bp.select", param);
		int count = dao.selectForInteger("bp.count", param);
		PageTemplate pt = new PageTemplate(list, pageCurr, pageCount, count, 5);
		return pt;
	}
	
	//插入方法
	public int insertbp(Map<String, Object> param)
	{
		int insert=dao.insert("bp.insert", param);
		return insert;
	}
	
	//更新方法
	public int updatebp(Map<String, Object> param) 
	{ 
		int update=dao.update("bp.update", param);
		return update;
	}
	
	public Map selectbpup(Map<String,Object> param)
	{	
		Map map =(Map) dao.selectForOne("bp.selectup", param);
		return map;
	}
	
	//删除方法
    public int updeletebp(Map<String,Object> param){
    	int delete=dao.update("bp.updelete", param);
    	return delete;
    }
    
  //彻底删除方法
    public int deletebp(Map<String,Object> param){
    	int delete=dao.update("bp.delete", param);
    	return delete;
    }
}